﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     xmlns:WinChrome="clr-namespace:WinChrome" 
    xmlns:Convertors="clr-namespace:WinChrome.Convertors" 
    xmlns:UI="clr-namespace:WinChrome.UI" 
    xmlns:shell="http://schemas.microsoft.com/winfx/2006/xaml/presentation/shell"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
    
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/WinChrome;component/UI/GlassResourceDictionary.xaml" />
        <ResourceDictionary Source="/WinChrome;component/UI/HistoryNavigatorStyles/Win7ResourceDictionary.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <JournalEntryUnifiedViewConverter x:Key="JournalEntryUnifiedViewConverter" />
    <Convertors:BooleanToInvisibilityConverter x:Key="booleanToInvisibilityConverter"/>
    <BooleanToVisibilityConverter x:Key="booleanToVisibilityConverter" />
   
    <!-- Custom NavigationWindow UI -->
    <Style x:Key="Win7NavigationWindow" TargetType="{x:Type WinChrome:SearchableNavigationWindow}">
        <Setter Property="MinWidth" Value="400"/>
        <!--<Setter Property="UI:GlassEffect.IsEnabled" Value="True" />
        <Setter Property="UI:GlassEffect.Thickness">
            <Setter.Value>
                <Thickness Top="35"/>
            </Setter.Value>
        </Setter>-->
        <Setter Property="shell:WindowChrome.WindowChrome">
            <Setter.Value>
                <shell:WindowChrome GlassFrameThickness="6,63,6,6" />
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate>

                    <DockPanel x:Name="mainDock"  LastChildFill="True"  
                  Margin="{Binding WindowNonClientFrameThickness, Source={x:Static shell:SystemParameters2.Current}}" >
                        <!-- The border is used to compute the rendered height with margins.
                                    topBar contents will be displayed on the extended glass frame.-->
                        <Border DockPanel.Dock="Top" ><!--Background="{TemplateBinding UI:GlassEffect.GlassBackground}">-->
                            <Grid SnapsToDevicePixels="True" Margin="0,2,0,8">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="80" MinWidth="80"/>
                                    <ColumnDefinition Width="*" MinWidth="150"/>
                                    <ColumnDefinition Width="128" MinWidth="128"/>
                                </Grid.ColumnDefinitions>
                                <UI:HistoryNavigator Margin="0,-1,0,-1"
                                        BackCommand="NavigationCommands.BrowseBack" 
                                        ForwardCommand="NavigationCommands.BrowseForward" 
                                        CommandTarget="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type NavigationWindow}}}" 
                                        CommandParameter="{Binding RelativeSource={RelativeSource Self}}"
                                                     Style="{StaticResource HistoryNavigatorWin7}">
                                    <UI:HistoryNavigator.ItemsSource>
                                        <MultiBinding Converter="{StaticResource JournalEntryUnifiedViewConverter}" >
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type NavigationWindow}}" Path="BackStack"/>
                                            <Binding RelativeSource="{RelativeSource FindAncestor, AncestorType={x:Type NavigationWindow}}" Path="ForwardStack"/>
                                        </MultiBinding>
                                    </UI:HistoryNavigator.ItemsSource>
                                </UI:HistoryNavigator>

                                <TextBox  Grid.Column="1"  IsReadOnly="True" BorderThickness="1" VerticalAlignment="Center"
								Style= "{DynamicResource InGlassTextBoxStyle}"
								 Text="{Binding Content.Title, ElementName=PART_NavWinCP}"  
                                          Margin="0,0,5,0" Height="23" />

                                <GridSplitter Grid.Column="1"  x:Name="gridSplitter1" Width="5" 
                                                  Background="Transparent" Focusable="False" 
                                               />
                    
                                <TextBox x:Name="PART_SearchBox"
                                    Style="{DynamicResource InGlassSearchBoxStyle}"
                                    Height="23" VerticalAlignment="Center" 
                                         Grid.Column="2" 
                                         WinChrome:SearchableNavigationWindow.HideIfNoSearch="false"
                                         Text="{Binding SearchText, RelativeSource={RelativeSource FindAncestor, AncestorLevel=1, AncestorType={x:Type WinChrome:SearchableNavigationWindow}}, UpdateSourceTrigger=PropertyChanged}" />
                            </Grid>
                        </Border>

                        <!-- Content area ie where Pages go -->
                        <Border 
                                BorderThickness="{TemplateBinding Border.BorderThickness}" 
                                BorderBrush="{TemplateBinding Border.BorderBrush}" 
                                Background="{TemplateBinding Panel.Background}">
                            <DockPanel>


                                <Grid DockPanel.Dock="Left">    
                                    <Grid Background="{StaticResource NavigationBackgroundBrush}" 
                                          Visibility="{Binding IsExpanded, Converter={StaticResource booleanToVisibilityConverter}, ElementName=navigationExpander}">
                                        <Grid Background="{StaticResource NavigationOverlayBrush}" >
                                            <ContentControl Content="{Binding Navigation, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type WinChrome:SearchableNavigationWindow}}}"/>
                                        </Grid>
                                        <Grid/>
                                    </Grid>
                                    <Expander x:Name ="navigationExpander" Visibility="{Binding ElementName=navigationPanel, Path=Content, Converter={StaticResource visibleIfNotNullConverter}}"
                                              HorizontalAlignment="Left" VerticalAlignment="Bottom" 
                                              ExpandDirection="Right" IsExpanded="True" />
                                </Grid>
                                <Border DockPanel.Dock="Top">
                                    <ContentControl Content="{Binding Content.(UI:NavigationPage.Alert), ElementName=PART_NavWinCP}"/>
                                </Border>

                                <ScrollViewer VerticalScrollBarVisibility="{Binding Content.(UI:NavigationPage.VerticalScroll), ElementName=PART_NavWinCP}">

                                    <AdornerDecorator >

                                        <Grid>
                                            <TextBlock Margin ="12,12,12,0"  
                                                    Text="{Binding Content.Title, ElementName=PART_NavWinCP}"  
                                                    Style="{StaticResource ControlPanelTitle}" />

                                            <ContentPresenter Margin="12,36,12,12"
                                                    Content="{TemplateBinding ContentControl.Content}" 
                                                    ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" 
                                                    ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
                                                    x:Name="PART_NavWinCP" ClipToBounds="True" />
                                        </Grid>
                                    </AdornerDecorator>
                                </ScrollViewer>
                            </DockPanel>
                        </Border>
                    </DockPanel>

                </ControlTemplate>
            </Setter.Value>
        </Setter>

        <!-- Initial NavigationWindow dimensions -->
        <!-- <Setter Property="Width" Value="400" />
        <Setter Property="Height" Value="300" />-->

    </Style>
</ResourceDictionary>